//
//  FPHomeProductCell.m
//  FinanceProject
//
//  Created by 陈显摆 on 2025/3/11.
//

#import "FPHomeProductCell.h"

@implementation FPHomeProductCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.contentView.backgroundColor = UIColor.clearColor;
    self.backgroundColor = UIColor.clearColor;
    
    self.backView.clipsToBounds = YES;
    self.backView.layer.cornerRadius = 5.f;
    
    self.titleLab.textColor = [UIColor hexColor:@"#3A3A3A"];
    
    self.tipLab.textColor = [UIColor hexColor:@"#FF9F38"];
    self.tipLab.clipsToBounds = YES;
    self.tipLab.layer.cornerRadius = 2.f;
    self.tipLab.backgroundColor = [UIColor hexColor:@"#FFF4E9"];
    
    self.tipLab1.textColor = [UIColor hexColor:@"#9A9A9A"];
    self.tipLab2.textColor = [UIColor hexColor:@"#9A9A9A"];
    
    self.amountLab1.textColor = MAIN_BLUE_COLOR;
    self.amountLab2.textColor = MAIN_BLUE_COLOR;
    
    self.applyBtn.backgroundColor = MAIN_BLUE_COLOR;
    self.applyBtn.clipsToBounds = YES;
    self.applyBtn.layer.cornerRadius = 15.f;
    [self.applyBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateNormal)];
    
}

- (void)analysisUIWithProductModel:(FPProductModel *)model {
    
    self.titleLab.text = model.productName;
    NSString *text = model.sellingPoint;
    self.tipLab.text = text;
    self.tipWidth.constant = [UIView widthWithString:text labelHeight:16.f fontSize:11.f] + 20.f;
    
    self.amountLab1.text = formatAmount([NSDecimalNumber decimalNumberWithString:model.loanAmount]);
    self.amountLab2.text = model.annualInterestRate;
    
    [self.logoImgView sd_setImageWithURL:[NSURL URLWithString:model.productLogo] placeholderImage:IMG(@"icon_home_placeholder")];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
